package 力扣日常刷题.木22二月.第13天219;

/**
 * @author 帅小伙
 * @date 2022/2/19
 * @description
 */
public class Demo94删除有序数组中的重复项 {


    public int removeDuplicates(int[] nums) {
        if(nums.length == 0) return 0;
        int ans = 1;
        int last = nums[0];
        for (int i = 1; i <nums.length ; i++) {
            if(nums[i] == last) continue;
            ans++;
            last = nums[i];
            nums[ans-1] = last;
        }
        return ans;
    }
}
